package com.py.framework.controller;

import com.py.framework.common.controller.SystemController;
import com.py.framework.core.rest.support.RestServiceResult;
import com.py.framework.service.FeedbackApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedHashMap;
import java.util.List;

/**
 * 联合奖惩反馈插件controller
 */
@RestController
@RequestMapping("/feedbackApi")
public class FeedbackApiController extends SystemController{

    @Autowired
    private FeedbackApiService feedbackApiService;

    /**
     * 远程调用检查登录用户是否存在并返回主键id
     * @param username
     * @param password
     * @return
     */
    @RequestMapping(value = "/checkLogin.do", method = RequestMethod.POST)
    @ResponseBody
    public RestServiceResult<Long> checkLogin(@RequestParam String username,
                                              @RequestParam String password) {
        return super.getSuccessRestServiceResult(feedbackApiService.selectUserId(username, password));
    }

    /**
     * 远程调用获取用户信息
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getUserInfo.do", method = RequestMethod.POST)
    @ResponseBody
    public RestServiceResult<LinkedHashMap> getUserInfo(@RequestParam String userId) {
        return super.getSuccessRestServiceResult(feedbackApiService.getUserInfo(userId));
    }
}
